package org.demoth.arkanoid;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * Created by IntelliJ IDEA.
 * User: daniil
 * Date: 20.05.11
 * Time: 22:27
 * To change this template use File | Settings | File Templates.
 */
public class Main {
    public static void main(String[] args) {
        ResourceManager.loadConfig("data/settings.xml");
        final Scene scene = ResourceManager.loadScene("data/scene1.xml");

        KeyAdapter keyAdapter = new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent keyEvent) {
                scene.gameObjects.get(4).x +=4;
                scene.gameObjects.get(2).x +=4;
                scene.gameObjects.get(3).x +=4;
            }
        };

        JFrame frame = new JFrame("Arkanoid 0.3d reference implementation") {
            @Override
            public void paint(Graphics graphics) {
                super.paint(graphics);
                Graphics2D graphics2D = (Graphics2D) graphics;
                for (GameObject object : scene.gameObjects) {
                    graphics2D.drawImage(object.graphics, (int) object.x, (int) object.y, null);
                }
            }
        };
        frame.addKeyListener(keyAdapter);
        frame.setIgnoreRepaint(true);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(ResourceManager.width, ResourceManager.height);

        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setResizable(false);
    }

}











